﻿@model IEnumerable<Backend.JYD.Model.Task.TaskStepInfo>
@using Backend.JYD.Common;
@using Backend.JYD.Model;
@using Backend.JYD.Model.Task;
@using Backend.JYD.Business;
@{
    ViewBag.Title = "任务流程详情";
    Layout = "~/Views/Shared/_LayoutWin.cshtml";

    var stepModel = ViewBag.TaskStepModeles as List<TaskStepModel>;
}
<div class="ui_pop_body" style="width: 850px; height: 450px;">
    <div>
        <table class="table1" width="100%" border="0" cellpadding="0" cellspacing="1">
        <thead>
            <tr>
                <th width="20px"></th>
                <th width="40px"><div class="th1">编码</div></th>
                <th width="40px">步骤号</th>
                <th width="100px">步骤名</th>
                <th width="80px">执行角色</th>
                <th width="80px">执行人</th>
                <th width="80px">状态</th>
                @*<th width="60px">操作人</th>*@
                <th width="90px">创建时间</th>
                <th width="90px">修改时间</th>
            </tr>
        </thead>
        <tbody>
        @if (Model != null)
        {
            int idx = 0;
            var empInfos = this.ViewBag.EmpInfos as List<EmpInfo>;
            var roleInfos = this.ViewBag.RoleInfos as List<RoleInfo>;

            foreach (var item in Model)
            {
                string empNames = string.Empty;
                string roleNames = string.Empty;
                string opName = string.Empty;
                if (empInfos != null)
                {
                    foreach (var info in empInfos)
                    {
                        if (("," + item.EmpIds + ",").Contains("," + info.EmpId + ","))
                        {
                            empNames += info.EmpName + ",";
                        }
                    }
                    empNames = empNames.Trim(',');
                    var opInfo = empInfos.Find(p => p.EmpId == item.OpId);
                    if (opInfo != null)
                    {
                        opName = opInfo.EmpName;
                    }
                }
                if (roleInfos != null)
                {
                    foreach (var info in roleInfos)
                    {
                        if (("," + item.RoleIds + ",").Contains("," + info.RoleId + ","))
                        {
                            roleNames += info.RoleName + ",";
                        }
                    }
                    roleNames = roleNames.Trim(',');
                }
                TaskStepModel step = stepModel == null ? null : stepModel.Find(p => p.StepId == item.StepId);

                idx++;
                 <tr>
                    <td>@idx</td>
                    <td>@item.TaskDetailId</td>
                    <td>@item.StepId</td>
                    <td>@(step == null ? string.Empty : step.StepName)</td>
                    <td>@roleNames</td>
                    <td>@empNames</td>
                    <td>@(TaskManager.GetTaskStatusCode(item.Status))</td>
                    @*<td>@opName</td>*@
                    <td>@item.CreateTime</td>
                    <td>@item.UpdateTime</td>
                 </tr>
            }
        }
        </tbody>
    </table>
    </div>
</div>

